package com.digua.base.base

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.digua.base.util.CollUtil.size

open class FragmentAdapter<T : Fragment> : FragmentPagerAdapter {
    var datas: MutableList<T>
        set(value) {
            field = value
            notifyDataSetChanged()
        }

    constructor(manager: FragmentManager, datas: MutableList<T> = mutableListOf()) : super(manager, BEHAVIOR_SET_USER_VISIBLE_HINT) {
        this.datas = datas
    }

    override fun getCount() = size(datas)

    override fun getItem(position: Int) = datas[position]

}